package sortArray;
/*
 * @lc app=leetcode.cn id=912 lang=java
 *
 * [912] 排序数组
 */

// @lc code=start
class Insert {
  public int[] sortArray(int[] nums) {
    for (int i = 0; i < nums.length; i++) {
      for (int j = i; j > 0; j--) {
        if (nums[j] < nums[j - 1]) {
          swap(nums, j, j - 1);
        } else {
          break;
        }
      }
    }
    return nums;
  }

  void swap(int[] nums, int i, int j) {
    int t = nums[i];
    nums[i] = nums[j];
    nums[j] = t;
  }
}
// @lc code=end
